/// <reference path="app.ts" />
/// <reference path="tsUnit.ts" />

module Tests {
    export class Registration {
        static compose(test: tsUnit.Test) {
            test.addTestClass(new Tests(), 'Tests');
        }
    }

    class Tests extends tsUnit.TestClass {
        private fizzBuzzHelper: FizzBuzzHelper;

        setUp() {
            this.fizzBuzzHelper = new FizzBuzzHelper(new Kata.FizzBuzz());
        }

        getOutputWith1Expect1() {
            this.fizzBuzzHelper.getOutputTestCase(1, '1');
        }

        getOutputWith2Expect2() {
            this.fizzBuzzHelper.getOutputTestCase(2, '2');
        }

        getOutputWithMultipleOf3ExpectFizz() {
            var expected = 'Fizz';
            this.fizzBuzzHelper.getOutputTestCase(3, expected);
            this.fizzBuzzHelper.getOutputTestCase(6, expected);
            this.fizzBuzzHelper.getOutputTestCase(9, expected);
        }

        getOutputWithMultipleOf5ExpectBuzz() {
            var expected = 'Buzz';
            this.fizzBuzzHelper.getOutputTestCase(5, expected);
            this.fizzBuzzHelper.getOutputTestCase(10, expected);
            this.fizzBuzzHelper.getOutputTestCase(20, expected);
        }

        getOutputWithMultipleOf3And5ExpectFizzBuzz() {
            var expected = 'FizzBuzz';
            this.fizzBuzzHelper.getOutputTestCase(15, expected);
            this.fizzBuzzHelper.getOutputTestCase(30, expected);
            this.fizzBuzzHelper.getOutputTestCase(45, expected);
        }

        getOutputWithMultipleOf7ExpectWhizz() {
            var expected = 'Whizz'
            this.fizzBuzzHelper.getOutputTestCase(7, expected);
            this.fizzBuzzHelper.getOutputTestCase(14, expected);
        }

        getOutputWithMultipleOf3And7ExpectFizzWhizz() {
            var expected = 'FizzWhizz';
            this.fizzBuzzHelper.getOutputTestCase(21, expected);
            this.fizzBuzzHelper.getOutputTestCase(42, expected);
        }

        getOutputWithMultipleOf5And7ExpectBuzzWhizz() {
            var expected = 'BuzzWhizz';
            this.fizzBuzzHelper.getOutputTestCase(35, expected);
            this.fizzBuzzHelper.getOutputTestCase(70, expected);
        }

        getOutputWithMultipleOf3And5And7ExpectFizzBuzzWhizz() {
            var expected = 'FizzBuzzWhizz';
            this.fizzBuzzHelper.getOutputTestCase(105, expected);
            this.fizzBuzzHelper.getOutputTestCase(210, expected);
        }
    }

    class FizzBuzzHelper extends tsUnit.TestClass {
        constructor(private fizzBuzz: Kata.FizzBuzz) {
            super();
        }

        getOutputTestCase(num: number, expected: string) {
            var result = this.fizzBuzz.getOutput(num);
            this.areIdentical(expected, result);
        }
    }
}

(function () {
    var test = new tsUnit.Test();
    Tests.Registration.compose(test);
    test.showResults(document.getElementById('result'), test.run());
} ());